<template>
  <div>
    登录页
    <input type="button" value="主页" @click="go2('home')" />
    <input type="button" value="注册" @click="go('/reg')" />
  </div>
</template>

<script>
export default {
  data() {
    return {};
  },

  components: {},

  methods: {
    //功能：跳转页面
    go(path) {
      //编程式导航
      this.$router.push(path); //写成路径  push('/home')
    },

    //功能：跳转页面并传参
    go2(name) {
      //方式一:params对象传参 params刷新会数据丢失
      this.$router.push({ name, params: { username: "旺旺" } });
      //方式二：动态路由传参  /home/1234
      // this.$router.push({ path: "/" + name + "/1234" });
      //方式三：query对象传参
      // this.$router.push({ name, query: { username: "旺旺" } });
    }
  }
};
</script>

<style scoped></style>
